@extends('default.layouts.companyPublic')

@section('title', '企业账户中心')
@section('headcss')
    @parent
    <link rel="stylesheet" type="text/css" href="{{asset('/default/css/company/myOrderPay.css')}}">
@endsection
@section('rightcon')
    <div class="right">
        <!--菜单-->
        <div class="jright">
            <div class="content">
                <div class="jobtitle">
                    <div class="tithead">
                        <ul>
                            <li><a href="{{ route('myOrder.index') }}">会员套餐</a></li>
                            <li class="active"><a href="{{ route('myOrder.list') }}">我的定单</a></li>
                            <li><a href="{{ url('company/member_records') }}">会员服务</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="rightContain">
            <div class="note"><i></i><span>我的订单</span></div>
            {{--提示--}}
            <form name="payForm" id="payForm" action="{{ route("myOrder.toPay") }}" method="post">
                {{ csrf_field() }}
                <input type="hidden" name="orderId" value="{{ $MyOrder->id }}">
                <input type="hidden" name="money" value="{{ $MyOrder->money }}">
                <div class="current">已选套餐：<span><i></i>{{ $MyOrder->myOrderWithVipPackage->vipname or '' }}</span></div>
                <div class="icon"><img src="{{ asset("/default/images/company/up.png") }}"></div>
                @if(!empty($MyOrder->myOrderWithVipPackage))
                <div class="info">
                    <p>
                        <span>套餐天数：<em>{{ $MyOrder->myOrderWithVipPackage->vip_days or '' }}</em>(天)</span>
                        <span>套餐积分：<em>{{ $MyOrder->myOrderWithVipPackage->vip_integral + $MyOrder->myOrderWithVipPackage->integral }}</em>(分)</span>
                    </p>
                    <p>
                        <span>套餐职位数：<em class="second">{{ $MyOrder->myOrderWithVipPackage->vip_post_number or '' }}</em>(个)</span>
                        <span>套餐简历数：<em class="second">{{ $MyOrder->myOrderWithVipPackage->vip_resume_number + $MyOrder->myOrderWithVipPackage->resume_number }}</em>(份)</span>
                    </p>
                </div>
                @else
                    <div class="info"><p>该套餐已下架</p></div>
                @endif
                <div class="payType">
                    <em>支付方式：</em>
                    {{--0=》未支付 1=》取消 2=》支付成功--}}
                    @if($MyOrder->stats == 0)
                        <input type="radio" name="payType" id="payType1" checked value="15">
                        <label for="payType1">
                            <img src="{{ asset('/default/images/company/pay_alipay.png') }}">
                        </label>
                        <input type="radio" name="payType" id="payType2" value="16">
                        <label for="payType2">
                            <img src="{{ asset('/default/images/company/pay_wxpay.png') }}">
                        </label>
                    @elseif($MyOrder->stats == 1)
                        <em class="cancel">定单已取消</em>
                    @elseif($MyOrder->stats == 2)
                        <em class="success">定单已支付</em>
                    @endif
                </div>
                <div class="money">支付金额：<em>{{ $MyOrder->money }}</em>元</div>
                <div class="button" id="button">
                    @if($MyOrder->stats == 0)
                        <input type="button"  id="toPay" value="立即支付" onclick="aliPay()">
                    @endif
                </div>
            </form>
        </div>
    </div>
@endsection
@section('footerjs')
    @parent
    <script type="text/javascript">

        //支付宝按钮
        $("#payType1").click(function(){
            $("#button").html('<input type="button" id="toPay" value="立即支付" onclick="aliPay()">');
        });
        //微信按钮
        $("#payType2").click(function(){
            $("#payForm").attr('target','_self');
            $("#button").html('<input type="button" id="toMpPay" value="立即支付">');
            //微信支付处理
            $("#toMpPay").click(function(){
                layer.open({
                    type: 1,
                    title: '微信支付扫一扫',
                    skin: 'layui-layer-rim', //加上边框
                    area: ['330px', '340px'], //宽高
                    content: "<div id='mpPayPng'><img src='{{ route("myOrder.toPay").'?orderId='.$MyOrder->id.'&payType=16' }}' width='280' height='280'></div>",

                    end:function(){
                        layer.confirm('套餐充值成功?', {
                                    btn: ['是的', '遇到点问题'] //按钮
                                },
                                function(){//success
                                    window.location.reload();
                                },
                                function(){//false
                                    @if(!empty($CrmUser->withService))
                                         @if(!empty($CrmUser->withService->phone))
                                            html = "<p class='crmInfo'>客服：{{ $CrmUser->withService->worker_name }}</p>"
                                            +"<p class='crmInfo'>座机号：{{ $CrmUser->withService->phone }}</p>";
                                        layer.open({
                                            type: 1,
                                            title: '您的专属客服信息',
                                            skin: 'layui-layer-rim', //加上边框
                                            area: ['200px', '100px'], //宽高
                                            content: html, //禁滚动条
                                            success: function(layero, index){
                                            },
                                            end:function(){}//点击完成事件后,显示内容后续操作
                                        });
                                    @endif
                                @endif
                            });
                    }//点击完成事件后,显示内容后续操作
                });

            });

        });
        //支付宝支付事件
        function aliPay(){
            $("#payForm").attr('target','_target');
            $("#payForm").submit();

            layer.confirm('套餐充值成功?', {
                    btn: ['是的', '遇到点问题'] //按钮
                },
                function(){//success
                    window.location.reload();
                },
                function(){//false
                    @if(!empty($CrmUser->withService))
                         @if(!empty($CrmUser->withService->phone))
                            html = "<p class='crmInfo'>客服：{{ $CrmUser->withService->worker_name }}</p>"
                            +"<p class='crmInfo'>座机号：{{ $CrmUser->withService->phone }}</p>";
                    layer.open({
                        type: 1,
                        title: '您的专属客服信息',
                        skin: 'layui-layer-rim', //加上边框
                        area: ['200px', '100px'], //宽高
                        content: html, //禁滚动条
                        success: function(layero, index){
                        },
                        end:function(){}//点击完成事件后,显示内容后续操作
                    });
                    @endif
                @endif
            });
        }
        $("#leftnav_order").addClass("active");
    </script>
@endsection